package com.cyt.${moduleName?replace('/', '.')}.controller;

import com.cyt.base.controller.BaseController;
import com.cyt.base.domain.vo.Result;
import com.cyt.base.domain.vo.ResultList;
import com.cyt.base.domain.vo.ResultPage;
import com.cyt.base.utils.ResultUtil;
import com.cyt.system.annotation.DataScope;
import com.cyt.system.annotation.OperateLog;
import com.cyt.system.constant.SysConstant;
import com.cyt.system.utils.TokenUtil;
import com.cyt.${moduleName?replace('/', '.')}.domain.dto.${entityName}Dto;
import com.cyt.${moduleName?replace('/', '.')}.domain.po.${entityName};
import com.cyt.${moduleName?replace('/', '.')}.domain.vo.${entityName}Vo;
import com.cyt.${moduleName?replace('/', '.')}.domain.vo.excel.${entityName}ImportVo;
import com.cyt.${moduleName?replace('/', '.')}.service.${entityName}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * ${description}-controller层
 *
 * @author ${authorName}
 * @date ${.now}
 */
@RestController
@Api(tags = "${description}")
public class ${entityName}Controller extends BaseController {

    @Resource
    private ${entityName}Service ${entityName?uncap_first}Service;

    /**
     * 分页查询${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return ResultPage<${entityName}>
     * @author ${authorName}
     * @date ${.now}
     */
    @DataScope
    @ApiOperation(value = "分页查询${description}")
    @ApiOperationSupport(order = 1, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/findPage.do")
    @OperateLog(name = "分页查询${description}", type = SysConstant.OPERATE_TYPE_QUERY, module = "${description}")
    public ResultPage<${entityName}> findPage(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ResultUtil.success(${entityName?uncap_first}Service.findPage(${entityName?uncap_first}Dto));
    }

    /**
     * 分页查询${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return ResultPage<${entityName}Vo>
     * @author ${authorName}
     * @date ${.now}
     */
    @DataScope
    @ApiOperation(value = "分页查询${description}")
    @ApiOperationSupport(order = 2, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/findVoPage.do")
    @OperateLog(name = "分页查询${description}", type = SysConstant.OPERATE_TYPE_QUERY, module = "${description}")
    public ResultPage<${entityName}Vo> findVoPage(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ResultUtil.success(${entityName?uncap_first}Service.findVoPage(${entityName?uncap_first}Dto));
    }

    /**
     * List查询${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return ResultList<${entityName}>
     * @author ${authorName}
     * @date ${.now}
     */
    @DataScope
    @ApiOperation(value = "List查询${description}")
    @ApiOperationSupport(order = 3, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/findList.do")
    @OperateLog(name = "List查询${description}", type = SysConstant.OPERATE_TYPE_QUERY, module = "${description}")
    public ResultList<${entityName}> findList(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ResultUtil.success(${entityName?uncap_first}Service.findList(${entityName?uncap_first}Dto));
    }

    /**
     * List查询${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return ResultList<${entityName}Vo>
     * @author ${authorName}
     * @date ${.now}
     */
    @DataScope
    @ApiOperation(value = "List查询${description}")
    @ApiOperationSupport(order = 4, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/findVoList.do")
    @OperateLog(name = "List查询${description}", type = SysConstant.OPERATE_TYPE_QUERY, module = "${description}")
    public ResultList<${entityName}Vo> findVoList(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ResultUtil.success(${entityName?uncap_first}Service.findVoList(${entityName?uncap_first}Dto));
    }

    /**
     * 对象查询${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return Result<${entityName}>
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "对象查询${description}")
    @ApiOperationSupport(order = 5, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/findOne.do")
    @OperateLog(name = "对象查询${description}", type = SysConstant.OPERATE_TYPE_QUERY, module = "${description}")
    public Result<${entityName}> findOne(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ResultUtil.success(${entityName?uncap_first}Service.findOne(${entityName?uncap_first}Dto));
    }

    /**
     * 对象查询${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return Result<${entityName}Vo>
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "对象查询${description}")
    @ApiOperationSupport(order = 6, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/findVoOne.do")
    @OperateLog(name = "对象查询${description}", type = SysConstant.OPERATE_TYPE_QUERY, module = "${description}")
    public Result<${entityName}Vo> findVoOne(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ResultUtil.success(${entityName?uncap_first}Service.findVoOne(${entityName?uncap_first}Dto));
    }

    /**
     * 保存${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return Result<?>
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "保存${description}")
    @ApiOperationSupport(order = 7, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/add.do")
    @OperateLog(name = "保存${description}", type = SysConstant.OPERATE_TYPE_UPDATE, module = "${description}")
    public Result<?> add(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ${entityName?uncap_first}Service.add(${entityName?uncap_first}Dto, TokenUtil.getUserId());
    }

    /**
    * 更新${description}
    *
    * @param ${entityName?uncap_first}Dto 参数传入对象
    * @return Result<?>
    * @author ${authorName}
    * @date ${.now}
    */
    @ApiOperation(value = "更新${description}")
    @ApiOperationSupport(order = 7, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/update.do")
    @OperateLog(name = "更新${description}", type = SysConstant.OPERATE_TYPE_UPDATE, module = "${description}")
    public Result<?> update(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ${entityName?uncap_first}Service.update(${entityName?uncap_first}Dto, TokenUtil.getUserId());
    }

    /**
     * 批量逻辑删除${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return Result<?>
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "批量逻辑删除${description}")
    @ApiOperationSupport(order = 8, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/remove.do")
    @OperateLog(name = "批量逻辑删除${description}", type = SysConstant.OPERATE_TYPE_REMOVE, module = "${description}")
    public Result<?> remove(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ${entityName?uncap_first}Service.remove(${entityName?uncap_first}Dto, TokenUtil.getUserId());
    }

    /**
     * 批量物理删除${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @return Result<?>
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "批量物理删除${description}")
    @ApiOperationSupport(order = 9, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/delete.do")
    @OperateLog(name = "批量物理删除${description}", type = SysConstant.OPERATE_TYPE_DELETE, module = "${description}")
    public Result<?> delete(@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        return ${entityName?uncap_first}Service.delete(${entityName?uncap_first}Dto);
    }

    /**
     * 下载导入模板
     *
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "下载导入模板")
    @ApiOperationSupport(order = 10, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/downloadExcel.do")
    @OperateLog(name = "下载导入模板", type = SysConstant.OPERATE_TYPE_EXPORT, module = "${description}")
    public void downloadExcel(HttpServletResponse response) {
        ${entityName?uncap_first}Service.downloadExcel(response);
    }

    /**
     * 导入${description}
     *
     * @param file 参数传入对象
     * @return Result<?>
     * @author ${authorName}
     * @date ${.now}
     */
    @ApiOperation(value = "导入${description}")
    @ApiOperationSupport(order = 11, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/importExcel.do")
    @OperateLog(name = "导入${description}", type = SysConstant.OPERATE_TYPE_IMPORT, module = "${description}")
    public ResultList<${entityName}ImportVo> importExcel(MultipartFile file) {
        return ${entityName?uncap_first}Service.importExcel(file, TokenUtil.getUserId());
    }

    /**
     * 导出${description}
     *
     * @param ${entityName?uncap_first}Dto 参数传入对象
     * @author ${authorName}
     * @date ${.now}
     */
    @DataScope
    @ApiOperation(value = "导出${description}")
    @ApiOperationSupport(order = 12, author = "${authorName}")
    @PostMapping("/${moduleName}/${functionName}/exportExcel.do")
    @OperateLog(name = "导出${description}", type = SysConstant.OPERATE_TYPE_EXPORT, module = "${description}")
    public void exportExcel(HttpServletResponse response,@RequestBody ${entityName}Dto ${entityName?uncap_first}Dto) {
        ${entityName?uncap_first}Service.exportExcel(response, ${entityName?uncap_first}Dto);
    }
}
